<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    
    <style>
        /*.parent{
            height:100px;
            width:100px;
            background: red;
            position:relative;

        }
        .child{
            height:50px;
            background:green;
            position: absolute;
        }*/
        /*子元素绝对定位，不会继承父元素的width*/

   .parent{
            width:100px;
            background: red;
            position:relative;

        }
   .child{
            width:50px;
            height:50px;
            background:green;
            position: absolute;
        }
        /*子元素绝对定位，父不会继承子元素的height*/
    </style>
</head>
<body>
    <div class="parent">
    <div class="child"></div>
    </div>
</body>
</html>